package com.itheima.controller;

import com.itheima.pojo.Order;
import com.itheima.service.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * (Order)表控制层
 *
 * @author guobuyi
 * @since 2021-01-20 16:46:46
 */
@RestController
@RequestMapping("order")
public class OrderController {
    @Value("${server.port}")
    private String port;

    /**
     * 服务对象
     */
    @Autowired
    private OrderService orderService;

    /**
     * @Author: guodong
     * @Date: 20:01 2021/1/21
     * @Parms [id]
     * @ReturnType: com.itheima.pojo.Order
     * @Description: 根据userId查询订单
    */
    @GetMapping("findOrderByUserId/{userId}")
    public Order findOrderByUserId(@PathVariable Integer userId) {
        Order order = orderService.findOrderByUserId(userId);
        order.setNote("订单服务端口: " + port);
        return order;
    }

}